﻿using System.Windows;

namespace OrderEntryProject
{
   /// <summary>
   /// Interaction logic for OrderWindow.xaml
   /// </summary>
   public partial class OrderWindow : Window
   {
      public string CustomerID { get; set; }

      public OrderWindow()
      {
         InitializeComponent();
      }

      private void btnCancel_Click(object sender, RoutedEventArgs e)
      {
         Close();
      }

      private void btnOk_Click(object sender, RoutedEventArgs e)
      {
         var ctx = (NorthwindDataContext) App.Current.Properties["ctx"];
         Order order = new Order
                          {
                             CustomerID = this.CustomerID,
                             OrderDate = dtOrder.SelectedDate,
                             RequiredDate = dtRequired.SelectedDate
                          };
         ctx.Orders.InsertOnSubmit(order);
         this.Close();
      }
   }
}
